﻿Public Class frmInsertarPlaneta
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim Validor As New ValidadorDeFormularios(Me, ErrorProvider1)
        Dim FormularioValido As Boolean = Validor.ValidarFormulario()

        If FormularioValido = False Then
            Return
        End If

        Dim strNombre As String = Me.txtString1.Text
        Dim numMasa As Decimal = Convert.ToDecimal(Me.txtDecimal1.Text)
        Dim numTemp As Decimal = Convert.ToDecimal(Me.txtDecimal2.Text)
        Dim numDDia As TimeSpan = New TimeSpan(Convert.ToDecimal(Me.txtIntegerDuracionDia.Text) * 24, 0, 0)
        Dim numDistancia As Decimal = Convert.ToDecimal(Me.txtDecimal3.Text)
        Dim numDAño As TimeSpan = New TimeSpan(Convert.ToDecimal(Me.txtDecimal4.Text) * 24, 0, 0)

        Dim lExito As Boolean
        lExito = objGestor.insertarPlaneta(strNombre, numMasa, numTemp, numDDia, numDistancia, numDAño)
        If lExito Then
            MsgBox("El Planeta se ingreso correctamente.")

            Me.txtString1.Text = ""
            Me.txtDecimal1.Text = ""
            Me.txtDecimal2.Text = ""
            Me.txtIntegerDuracionDia.Text = ""
            Me.txtDecimal3.Text = ""
            Me.txtDecimal4.Text = ""
            Me.txtString1.Focus()
        Else
            MsgBox("Planeta No fue Registrado, por favor verifique...")
        End If
    End Sub

    Private Sub frmInsertarPlaneta_Activated(sender As Object, e As EventArgs) Handles Me.Activated
        ModuloGeneral.Centrar(Me.Panel1)
    End Sub

    Private Sub frmInsertarPlaneta_ResizeEnd(sender As Object, e As EventArgs) Handles MyBase.ResizeEnd
        ModuloGeneral.Centrar(Me.Panel1)
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Me.Dispose()
    End Sub

End Class